﻿using Island;
using System;
using System.Collections.Generic;

class ActorManager : Singleton<ActorManager>
{
    public string LocalID;
    public Actor LocalActor;
    Dictionary<string, Actor> actors = new Dictionary<string, Actor>();
    Dictionary<string, Account> accounts = new Dictionary<string, Account>();
    
    public Dictionary<string, Actor> Actors
    {
        get
        {
            return actors;
        }
    }

    public void AddActor(PBAccount pb, Actor actor)
    {
        actors.Add(pb.id, actor);      
        actor.account = Account.FromPB(pb);
    }

    public void AddAccount(PBAccount pb)
    {
        Account acc = new Account();
        acc.id = pb.id;
        acc.sex = pb.sex;
        accounts.Add(pb.id, acc);
    }

    public void AddActor(string id, Actor actor)
    {
        actors.Add(id, actor);
        actor.account.id = id;
    }

    public void RemoveActor(string username)
    {
        actors.Remove(username);
    }

    public Actor GetActor(string username)
    {
        return actors[username];
    }
    public Dictionary<string, Actor> GetActors()
    {
        return actors;
    }
    public Actor GetLocal()
    {
        return actors[LocalID];
    }
}
